package com.example.controller;

import com.example.entity.SocketEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author zy
 */
@RestController
@RequestMapping("/v1")
public class TestController {

    @RequestMapping("/a")
    public String a(Integer id, Integer type) {
        System.out.println("id = " + id);
        System.out.println("type = " + type);
        System.err.println("123456");
        return "123456";
    }

    /**
     * 群发推送消息
     */
    @RequestMapping("/pushMessage")
    public String pushMessage(String text) {
        SocketEntity.SESSION_CURRENT_MAP.forEach((item, session) -> {
            try {
                item.sendText(text);
            } catch (IOException ioException) {
                ioException.printStackTrace();
            }
        });
        return "ok";
    }
}
